<template>
    <div>
        <el-form
                ref="dataForm"
                status-icon
                :model="form"
                :rules="rules"
                label-width="0px"
        >
            <template>
                <div>
                    <h5>基本信息</h5>
                    <el-divider></el-divider>
                </div>
            </template>
            <el-descriptions :column="4" border>
                <el-descriptions-item labelStyle="width: 10%" contentStyle="width: 15%">
                    <template slot="label"> 姓名</template>
                    <div>{{ form.name }}</div>
                </el-descriptions-item>

                <el-descriptions-item labelStyle="width: 10%" contentStyle="width: 15%">
                    <template slot="label">性别</template>
                    <div>{{ form.sex }}</div>
                </el-descriptions-item>
                <el-descriptions-item labelStyle="width: 10%" contentStyle="width: 15%">
                    <template slot="label">身份证号码</template>
                    <div>{{ form.sfz }}</div>
                </el-descriptions-item>

                <el-descriptions-item labelStyle="width: 10%" contentStyle="width: 15%">
                    <template slot="label">出生日期</template>
                    <div>{{ form.birthday }}</div>
                </el-descriptions-item>
                <el-descriptions-item labelStyle="width: 10%" contentStyle="width: 15%">
                    <template slot="label">系统唯一识别码</template>
                    <div>{{ form.id_num }}</div>
                </el-descriptions-item>
                <el-descriptions-item labelStyle="width: 10%" contentStyle="width: 15%">
                    <template slot="label">电话号码</template>
                    <div>{{ form.phone }}</div>
                </el-descriptions-item>

                <el-descriptions-item
                        labelStyle="width: 10%"
                        contentStyle="width: 90%"
                        span="4"
                >
                    <template slot="label">联系地址</template>
                    <div>
                        {{ form.province_name }} {{ form.city_name }}
                        {{ form.district_name }} {{ form.town_name }}
                        {{ form.village_name }} {{ form.address }}
                    </div>
                </el-descriptions-item>

            </el-descriptions>

            <template>
                <div>
                    <h5>病理检查</h5>
                    <el-divider></el-divider>
                </div>
            </template>

            <el-descriptions :column="4" border>

                <el-descriptions-item labelStyle="width: 10%" contentStyle="width: 15%">
                    <template slot="label"><span class="red">*</span>病理号</template>
                    <el-form-item prop="pathology_code">
                        <el-input v-model="form.pathology_code" placeholder="请输入病理号"></el-input>
                    </el-form-item>
                </el-descriptions-item>

                <el-descriptions-item labelStyle="width: 10%" contentStyle="width: 15%">
                    <template slot="label"><span class="red">*</span>标本类型</template>
                    <el-form-item prop="pathology_type">
                        <el-select clearable placeholder="请选择" style="width: 100%" v-model="form.pathology_type">
                            <el-option
                                    :key="item.value"
                                    :label="item.text"
                                    :value="item.value"
                                    v-for="item in pathologyTypeList"
                            >
                            </el-option>
                        </el-select>
                    </el-form-item>
                </el-descriptions-item>

                <el-descriptions-item labelStyle="width: 10%" contentStyle="width: 15%">
                    <template slot="label"><span class="red">*</span>活检日期</template>
                    <el-form-item prop="biopsy_date">
                        <el-date-picker
                                style="width:100%"
                                v-model="form.biopsy_date"
                                type="date"
                                placeholder="选择日期"
                                :value-format="'yyyy-MM-dd'"
                                clearable
                        >
                        </el-date-picker>
                    </el-form-item>
                </el-descriptions-item>

                <el-descriptions-item labelStyle="width: 10%" contentStyle="width: 15%">
                    <template slot="label"><span class="red">*</span>病理报告日期</template>
                    <el-form-item prop="pathology_date">
                        <el-date-picker
                                style="width:100%"
                                v-model="form.pathology_date"
                                type="date"
                                placeholder="选择日期"
                                :value-format="'yyyy-MM-dd'"
                                clearable
                        >
                        </el-date-picker>
                    </el-form-item>
                </el-descriptions-item>

                <el-descriptions-item labelStyle="width: 10%" contentStyle="width: 15%">
                    <template slot="label"><span class="red">*</span>病理诊断</template>
                    <el-form-item prop="pathology_diagnose">
                        <el-select clearable placeholder="请选择" style="width: 100%" v-model="form.pathology_diagnose">
                            <el-option
                                    :key="item.value"
                                    :label="item.text"
                                    :value="item.value"
                                    v-for="item in pathologyDiagnoseList"
                            >
                            </el-option>
                        </el-select>
                    </el-form-item>
                </el-descriptions-item>

                <el-descriptions-item span="3" labelStyle="width: 10%" contentStyle="width: 65%">
                    <template slot="label"> 备注</template>
                    <el-form-item prop="pathology_remark">
                        <el-input type="textarea" v-model="form.pathology_remark"></el-input>
                    </el-form-item>
                </el-descriptions-item>

            </el-descriptions>

            <el-descriptions :column="1" border v-if="dialogStatus !== 'formal'">
                <el-descriptions-item labelStyle="width: 10%" contentStyle="width: 90%">
                    <el-form-item label=" ">
                        <el-button @click="handleDialogVisible(false)" size="small">取 消</el-button>
                        <el-button type="primary" @click="update()" size="small">确 定</el-button>
                    </el-form-item>
                </el-descriptions-item>
            </el-descriptions>
        </el-form>
    </div>
</template>

<script>
    import {createData, updateData} from '@/api/data/data';
    import {listMember} from "@/api/member/member";
    import moment from "moment";

    export default {
        props: ["rowData", "dialogStatus"],
        components: {},
        data() {
            return {
                form: {
                    id: "",
                    pathology_code:"",  //病理号
                    pathology_type:"",  //标本类型
                    biopsy_date:"",  //活检日期
                    pathology_date:"",  //病理报告日期
                    pathology_diagnose:"",  //病理诊断
                    pathology_remark:"",  //备注
                    pathology_stauts: 0,
                    scene: 'pathology',
                },
                rules: {
                    pathology_code: [{required: true, message: "请输入病理号", trigger: "blur"}],
                    pathology_type: [{required: true, message: "请选择标本类型", trigger: "blur"}],
                    biopsy_date: [{required: true, message: "请选择活检日期", trigger: "blur"}],
                    pathology_date: [{required: false, message: "请选择病理报告日期", trigger: "blur"}],
                    pathology_diagnose: [{required: true, message: "请输入病理诊断", trigger: "blur"}],
                },
                updateLoading: false,
                memberList: [],
                pathologyTypeList: [
                    {text: "气管镜活检", value: 1},
                    {text: "穿刺活检", value: 2},
                    {text: "开胸活检", value: 3},
                    {text: "手术切除标本", value: 4},
                    {text: "胸水", value: 5}
                ],
                pathologyDiagnoseList: [
                    {text: "鳞状细胞癌（包括原位癌）", value: 1},
                    {text: "鳞状上皮重度异性增生", value: 2},
                    {text: "鳞状上皮中度异性增生", value: 3},
                    {text: "鳞状上皮轻度异性增生", value: 4},
                    {text: "鳞状上皮化生", value: 5},
                    {text: "基底细胞增生", value: 6},
                    {text: "腺癌", value: 7},
                    {text: "非典型腺瘤样增生", value: 8},
                    {text: "原位腺癌", value: 9},
                    {text: "微小浸润癌", value: 10},
                    {text: "浸润性腺癌（备注中注明亚型）", value: 11},
                    {text: "浸润性腺癌变异型 （备注中注明亚型）", value: 12},
                    {text: "大细胞癌", value: 13},
                    {text: "小细胞癌", value: 14},
                    {text: "腺鳞癌", value: 15},
                    {text: "肉瘤样癌", value: 16},
                    {text: "小涎腺来源肿瘤（粘液表皮样癌,腺样囊性癌）", value: 17},
                    {text: "类癌", value: 18},
                    {text: "非典型类癌", value: 19},
                    {text: "微瘤", value: 20},
                    {text: "考虑癌", value: 21},
                    {text: "不除外癌", value: 22},
                    {text: "慢性炎症", value: 23},
                    {text: "不能明确诊断(如组织挤压严重，坏死组织等）", value: 24},
                    {text: "未见明显异常", value: 25},
                    {text: "其他", value: 26}
                ],
            };
        },
        created() {
            this.getListMember();
            if (this.dialogStatus == "update" || this.dialogStatus == "formal") {
                this.form = {...this.rowData};

                this.form.sarcoidosis = this.form.sarcoidosis ? JSON.parse(this.form.sarcoidosis) : [];
                this.form.lymph = this.form.lymph ? JSON.parse(this.form.lymph) : [];
                this.form.lump = this.form.lump ? JSON.parse(this.form.lump) : [];

                if (!this.form.biopsy_date) {
                    this.form.biopsy_date = moment().format('YYYY-MM-DD');
                }
                if (!this.form.pathology_date) {
                    this.form.pathology_date = moment().format('YYYY-MM-DD');
                }
            }
        },
        methods: {
            getListMember() {
                let params = {
                    user_name: "",
                    status: "",
                    institution_id: this.$store.state.member.institution_id,
                    pageSize: 1000,
                    page: 1,
                };
                listMember(params).then((res) => {
                    if (res.code === 200) {
                        this.memberList = res.data.data;
                    } else {
                        this.msgError(res.msg);
                    }
                });
            },
            //父页面的回调事件
            handleDialogVisible(isUpdate) {
                this.dialogVisible = false;
                this.$emit("childByDialogVisible", this.dialogVisible, isUpdate);
            },
            //修改
            update() {
                this.form.scene = 'pathology';
                this.$refs["dataForm"].validate((valid) => {
                    if (valid) {
                        this.updateLoading = true;
                        updateData(this.form).then((response) => {
                            this.updateLoading = false;
                            if (response.code == 200) {
                                this.msgSuccess(response.msg);
                                this.handleDialogVisible(true);
                            }
                        });
                    }
                });
            },
        },
        watch: {},
    };
</script>
<style lang="scss" scoped="scoped">
    .el-form-item {
        margin: 0px;
    }

    .red {
        color: red;
    }

    .el-ul {
        list-style: none;
        padding: 0;
    }

    .el-list-li {
        float: left;
        position: relative;
        padding: 10px 10px 0px 0px;
    }

    .el-icon-circle-close {
        position: absolute;
        top: 0px;
        right: 0px;
        z-index: 2;
        font-size: 20px;
    }
</style>
